{% extends 'blank.html.twig' %}
{% block body %}
    <article class="page-container">
        <form class="form form-horizontal" id="form-appversion-add" method="post" action="">
            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>App的类型：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <select class="select" size="1" name="apptype" id="apptype">
                        <option value="" selected>请选择类型</option>
                        <option value="1">Android</option>
                        <option value="2">IOS</option>
                    </select>
                </div>
                <div class="formControls col-xs-3 col-sm-3"></div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>内部版本号：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <input type="text" class="input-text" autocomplete="off" value=""  id="version" name="version">
                </div>
                <div class="form-label col-xs-3 col-sm-3"></div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>外部版本号：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <input type="text" class="input-text" value="" placeholder="" id="versioncode" name="versioncode">
                </div>
                <div class="form-label col-xs-3 col-sm-3"></div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>是否强制更新：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <select class="select" size="1" name="isforce" id="isforce">
                        <option value="" selected>请选择</option>
                        <option value="1">是</option>
                        <option value="2">否</option>
                    </select>
                </div>
                <div class="form-label col-xs-3 col-sm-3"></div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>安装包地址：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <input type="text" class="input-text" value="" placeholder="" id="apkurl" name="apkurl">
                </div>
                <div class="form-label col-xs-3 col-sm-3"></div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>更新说明：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <textarea  class="textarea" value="" placeholder="说点什么...最少输入10个字符" id="upgradepoint" name="upgradepoint"></textarea>
                </div>
                <div class="form-label col-xs-3 col-sm-3"></div>
            </div>

            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>
{% endblock %}

{% block footer %}
    {{parent()}}
    <script type="text/javascript" src="/AbsSR/web/static/huiadmin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
    <script type="text/javascript" src="/AbsSR/web/static/huiadmin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
    <script type="text/javascript" src="/AbsSR/web/static/huiadmin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
    <script type="text/javascript">
        $(function(){
            $("#form-appversion-add").validate({
                rules:{
                    apptype:{
                        required:true
                    },
                    version:{
                        required:true,
                    },
                    versioncode:{
                        required:true,
                    },
                    isforce:{
                        required:true,
                    },
                    apkurl:{
                        required:true,
                    },
                    upgradepoint:{
                        required:true,
                    }

                },
                onkeyup:false,
                focusCleanup:true,
                success:"valid",
                submitHandler:function(form){
                    versionAjaxSubmit();
                    var index = parent.layer.getFrameIndex(window.name);
                    window.parent.location.reload();
                    parent.layer.close(index);
                }
            });
        });
        /**
         * @abstract ajax提交页面值
         */
        function versionAjaxSubmit(){
            $.ajax({
                type:'POST',
                url:'{{ path("version_add") }}',
                data:{
                    formdata:$('#form-appversion-add').serialize()
                },
                success:function(msg){
                    if(msg == 'ok'){//存储没有成功
                        layer.alert('存储成功');
                    }else{
                        layer.alert('新增失败');
                        return false;
                    }
                }
            });
        }
    </script>
{% endblock %}
